package com.jtcoding.chat.common.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jason.tang
 * @created 2019-02-18 15:30
 * @describe 
*/

public enum ResultCode {

    /** 成功状态码 */
    SUCCESS("OK", "success"),

    /** 默认错误:G00? */
    SYSTEM_ERROR("G001", "非常抱歉! 当前系统发呆了..."),

    PARAM_IS_INVALID("G002", "请求参数无效"),

    OPERATION_FAILURE("G003", "操作失败"),

    REPEAT_OPERATION("G004", "重复操作"),

    INCORRECT_UPDATING("G005", "不正确的的条件更新或源数据已经被修改"),

    /** 用户相关:E00? */
	USER_LOGIN_ERROR("E001", "登录ID或密码无效"),

    INVALID_OLD_PASSWORD("E002", "旧密码无效"),

    EMAIL_PHONE_ALREADY_EXISTS("E003", "邮箱或手机号已存在"),

    /** 资源相关:R00? */
    FILE_DOES_NOT_EXIST("R001", "文件不存在"),

    SERVICE_NOT_EXISTS("R002", "服务不存在!请联系管理员注册可用的服务。"),

    SERVICE_EXPIRED("R003", "服务已经过期!请联系管理员重新激活服务。"),

    UPDATE_FAILURE("R004", "上传失败");

    private String code;
    private String msg;

    ResultCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String code() {
        return this.code;
    }

    public String msg() {
        return this.msg;
    }

    //校验重复的code值
    public static void main(String[] args) {
        ResultCode[] ApiResultCodes = ResultCode.values();
        List<String> codeList = new ArrayList<String>();
        for (ResultCode ApiResultCode : ApiResultCodes) {
            if (codeList.contains(ApiResultCode.code)) {
            	//打印重复的code
                System.out.println(ApiResultCode.code);
            } else {
                codeList.add(ApiResultCode.code());
            }
        }
    }

}
